package com.dkakunsi.monev.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="PROGRAM")
public class Program implements MonevNameableEntity {
	private int id;
	private String nama;
	private Program parent;
	private List<Program> subProgram;
	private List<Kegiatan> daftarKegiatan;
	
	public Program(){}
	
	public Program(String nama) {
		this.setNama(nama);
	}
	
	@Id @GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id", length=11, nullable=false)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name="nama", length=255, nullable=false)
	public String getNama() {
		return nama;
	}

	public void setNama(String nama) {
		this.nama = nama;
	}

	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="parent", nullable=true)
	public Program getParent() {
		return parent;
	}

	public void setParent(Program parent) {
		this.parent = parent;
	}

	@OneToMany(mappedBy="parent", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
	public List<Program> getSubProgram() {
		return subProgram;
	}

	public void setSubProgram(List<Program> subProgram) {
		this.subProgram = subProgram;
	}

	@OneToMany(mappedBy="program",fetch=FetchType.LAZY, cascade=CascadeType.ALL)
	public List<Kegiatan> getDaftarKegiatan() {
		return daftarKegiatan;
	}

	public void setDaftarKegiatan(List<Kegiatan> daftarKegiatan) {
		this.daftarKegiatan = daftarKegiatan;
	}

}
